<template>
  <div>
    <MineTitleVue/>
    <div class="login-title">{{isphone?myphone+'，欢迎回来！':''}}</div>
    <!-- <div>{{ login }}</div> -->
    <div class="account-phone">{{myphone}}</div>
        <div class="phone-input">
            <input style="width: 240px;" type="password" placeholder="设置密码" v-model="pwd" @input="lengthLimit">
            <!-- <input type="password" placeholder="请输入密码" v-model="pwd" @input="lengthLimit"> -->
        </div>
        <van-button class="register" @click="createNewAccount" v-show="confirm" round block type="info" >注册</van-button>
  </div>
</template>

<script>
import { Toast } from 'vant';
import MineTitleVue from "@/components/Mine/MineTitle.vue"
import { mapState } from 'vuex'

export default {
    props:['myphone'],
    data(){
        return{
            pwd:'',
            isphone:false,
            confirm:false
        }
    },
    methods:{
        lengthLimit(){
            this.pwd=this.pwd.trim()
            // 当长度大于6
            if(this.pwd.trim().length===6){
                this.confirm=true
            }
        },
        createNewAccount(){
           let a = { account: this.myphone,
            password: this.pwd}
            this.$store.commit("createNewAccount",a)
            this.$router.push({name:"login"})
            Toast("注册成功，请重新登录")
        }
    },
    computed: mapState(['login']),
    
    components:{
        MineTitleVue,
    }
}
</script>

<style lang="scss" scoped>
 .login-title{
        font-size: 14px;
        width: 100%;
        text-align: center;
        margin-bottom: 20px;
    }
    .account-phone{
            color:#333;
            width: 150px;
            margin: 20px auto;
            font-size: 24px;
            line-height: 30px;
        }
.phone-input{
    width: 230px;
            // height: 40px;
            display: flex;
            margin: 0 auto;
            background: rgba(240,240,240,1);
            // background-color: #fff;
            border: #fff 1px solid;
            padding: 10px 0 10px 10px;
            border-radius: 12px;
            line-height: 20px;
            input{
              background: rgba(240,240,240,1);
                width: 140px;
                height: 20px;
                padding: 0 10px;
                box-sizing: border-box;
                caret-color: var(--yellow);
                border: none;
            }
            input::-webkit-input-placeholder{
                color: #cfcfcf;
            }
            input::-moz-placeholder{   /* Mozilla Firefox 19+ */
                color: #cfcfcf;
            }
            input:-moz-placeholder{    /* Mozilla Firefox 4 to 18 */
                color: #cfcfcf;
            }
            input:-ms-input-placeholder{  /* Internet Explorer 10-11 */
                color: #cfcfcf;
            }
        }
        .register{
            width: 80%;
            margin: 0 auto;
            margin-top: 50px;
        }
</style>